<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <style>
    .box {
      width: 150px;
      height: 150px;
      background: yellowgreen;
    }

    /* //显示
    .v-enter
    .v-enter-active
    .v-enter-to

    //隐藏
    .v-leave
    .v-leave-active
    .v-leave-to */
    .fade-enter {
      opacity: 0;
    }

    .fade-enter-active {
      transition: all 2s;
      animation: move 2s;
    }

    .fade-enter-to {
      opacity: 1;
    }


   
    .fade-leave{
      opacity: 1;
    } 
    .fade-leave-active{
      transition: all 2s;
      animation: move 2s;
    } 
    .fade-leave-to{
      opacity: 0;
    }


    @keyframes move {
      0% {
        transform: rotate(0deg);
      }
      25% {
        transform: rotate(90deg);
      }
      50% {
        transform: rotate(180deg);
      }
      75% {
        transform: rotate(270deg);
      }
      100% {
        transform: rotate(360deg);
      }
      
    }
  </style>
</head>

<body>
  <div id="app">

    <button @click="isShow=!isShow">显示/隐藏</button>
    <transition name="fade" :duration="{ enter: 5000, leave: 5000 }"
    
    v-on:before-enter="beforeEnter"
  
    v-on:before-leave="beforeLeave"
    
    >
      <div class="box" v-if='isShow'>
      </div>
    </transition>



  </div>

  <script>

    var vm = new Vue({
      el: '#app',
      data:{
        isShow:true
      },
      methods:{
        beforeEnter(){
          console.log('beforeEnter')
        },
        beforeLeave(){
          console.log('beforeLeave')
        }

      }
    })
  </script>

</body>

</html>